Ext.namespace("Issue");

Issue.View = function(p) {
	this.parentWin=p
	this.hdIssueId = new Ext.form.Hidden({name:'superviseId'});
	this.txtIssueTitle = new Ext.form.TextField({
		fieldLabel: '问题标题',
		name:'superviseTitle',
		disabled:true,
		width: 320
	});	
	this.txtManagerName = new Ext.form.TextField({
		fieldLabel: '受理人',
		name:'managerName',
		width: 120,
		disabled:true
	});	
	this.txtIssueContent = new Ext.form.TextArea({
		fieldLabel: '问题描述',
		name:'superviseContent',
		disabled:true,
		height:60,
		width: 540
	});
	this.typeStore  = new Ext.data.ArrayStore({
        	fields: ['value', 'name'],
        	data: OMS.ISSUE_TYPE2
    });
	this.txtIssueType = new Ext.form.ComboBox({
		width: 120,
		fieldLabel: '问题类别',
		name:'issueType',
		store: this.typeStore,
		value:"1",	
        valueField: 'value',
        displayField: 'name',
        disabled:true,
        mode: 'local',
        triggerAction: 'all',
        selectOnFocus: true
	});
	this.dtIssueDate = new Ext.form.DateField({
    	fieldLabel: '提问时间',
    	name:'issueDate',
    	disabled:true,
		width: 120,
		format: 'Y-m-d'
	});
	this.typeLebel  = new Ext.data.ArrayStore({
        	fields: ['value', 'name'],
        	data: OMS.ISSUE_LEVEL2
    });
	this.txtInstancyLevel = new Ext.form.ComboBox({
		width: 120,
		fieldLabel: '紧急程度',
		name:'instancyLevel',
		store: this.typeLebel,
		value:"0",	
        valueField: 'value',
        displayField: 'name',
        disabled:true,
        mode: 'local',
        triggerAction: 'all',
        selectOnFocus: true
	});
	this.txtCreateName = new Ext.form.TextField({
		fieldLabel: '填报人',
		name:'createName',
		width: 120,
		disabled:true
	});
	this.txtDeptName = new Ext.form.TextField({
		fieldLabel: '营业厅',
		name:'deptName',
		width: 120,
		disabled:true
	});
	this.txtReportDeptName = new Ext.form.TextField({
		fieldLabel: '受理部门',
		name:'reportDeptName',
		width: 120,
		disabled:true
	});
	this.txtNotion = new Ext.form.TextArea({
		fieldLabel: '处理意见',
		name:'notion',
		width: 540,
		height: 40,
		disabled:true
	});
	this.txtCompleteDate =  new Ext.form.DateField({
    	fieldLabel: '完成时限',
    	name:'completeDate',
    	width:120,
    	disabled:true,
		format: 'Y-m-d'
	});	
	this.txtDispatchDate =  new Ext.form.DateField({
    	fieldLabel: '批示日期',
    	name:'dispatchDate',
    	width:120,
    	disabled:true,
		format: 'Y-m-d'
	});
	this.txtInspectorName = new Ext.form.TextField({
        fieldLabel: '执行人',
        name:'inspectorName',
        width: 240,
        disabled:true
    });
	this.txtFulfill = new Ext.form.TextArea({
		fieldLabel: '落实情况',
		name:'fulfill',
		width: 540,
		height: 40,
		disabled:true
	});
	this.files=new Ext.Container({ layout: 'column', border: false, defaults: {layout: 'form', border: false},
	        	items: []
	    });
	this.form = new Ext.FormPanel({
		bodyStyle: 'padding: 5px 5px 0',
        labelWidth: 70,
        labelAlign: 'right',
        region:'north',	
		height: 230,
		frame:true,
		items: [{ layout: 'column', border: false, defaults: {layout: 'form', border: false},
	        	items: [ { columnWidth: .33, items: [this.txtIssueType]},
	        			 { columnWidth: .33, items: [this.txtReportDeptName]},
	        	         { columnWidth: .33, items: [this.dtIssueDate] } ]
	    	},this.txtIssueContent,{ layout: 'column', border: false, defaults: {layout: 'form', border: false},
	        	items: [ { columnWidth: .33, items: [this.txtInstancyLevel] },
	        	         { columnWidth: .33, items: [this.txtCreateName]},
	        	         { columnWidth: .33, items: [this.txtDeptName]} ]
	    	},this.txtNotion,{ layout: 'column', border: false, defaults: {layout: 'form', border: false},
	        	items: [ { columnWidth: .33, items: [this.txtCompleteDate] },
	        	         { columnWidth: .66, items: [this.txtInspectorName]} ]
	    	},this.files
	    ]
    });
	this.store = new Ext.data.JsonStore({
	    url: '../superviseIssue/listFeedback.form?timesnap=' + Date.parse(new Date()),
	    root: 'result',
	    totalProperty: 'total',
        remoteSort: true,
	   fields: ['taskExeId','taskExeUpdateDate','taskId','taskExeUserId','taskExePerformType',
	    'taskExeDispatcherId','taskExeStatus','taskExePercent','taskExeBackStatus','content',
	    'taskExeUserName']
	});
	//this.store.setDefaultSort('taskFeedbackId', 'desc');
	this.renderTaskStatus = function(value){
		return OMS.TASKSEXESTATUS[value];
	}
	this.columns =  [
	    {header: '执行表ID', sortable: true, align: 'right',width: 20,hidden:true,dataIndex: 'taskExeId'},
	    {header: '负责人ID', sortable: true, align: 'center',width: 20,hidden:true,dataIndex: 'taskExeUserId'},
	    {header: '执行人', sortable: true, align: 'center',width: 20,dataIndex: 'taskExeUserName'},
		{header: '更新日期', sortable: true, align: 'right',width: 20,dataIndex: 'taskExeUpdateDate'},
		{header: '对应ID', sortable: true, align: 'right',width: 20,hidden:true,dataIndex: 'taskId'},		
		{header: '执行类型', sortable: true, align: 'right',width: 20,hidden:true,dataIndex: 'taskExePerformType'},
		{header: '派送人', sortable: true, align: 'center',width: 20,hidden:true,dataIndex: 'taskExeDispatcherId'},
		{header: '完成状态', sortable: true, align: 'right',width: 20,dataIndex: 'taskExeStatus',renderer:this.renderTaskStatus},
		{header: '完成百分比', sortable: true, align: 'right',width: 20,hidden:true,dataIndex: 'taskExePercent'},
		{header: 'TASK_EXE_BACK_STATUS', sortable: true, align: 'right',hidden:true,width: 20,dataIndex: 'taskExeBackStatus'},
		{header: '意见内容', sortable: true, align: 'center',dataIndex: 'content'}
	];
	
	this.grid = new Ext.grid.GridPanel({
		title:'任务反馈情况',
		region: 'center',
		cm: new Ext.grid.ColumnModel(this.columns),
		store:this.store,
		height: 180,
		viewConfig: { forceFit: true }
	});	
	Issue.View.superclass.constructor.call(this, {
		title: '查看厅问题',        
        width:700,
		height:420,
		resizable: false,
        modal: true,
        autoScroll: true,
		closeAction:'hide',
        items: [this.form,this.grid],
        buttons: [{
            text: '关闭',
            scope: this,
            handler: function() {
	        	this.hide();
        	}
        }],
        buttonAlign:'center'
	});
};
Ext.extend(Issue.View, Ext.Window, {
	initWin:function(data){		
		this.form.getForm().setValues(data);		
		this.grid.store.load({
			params:{superviseId:data.superviseId}
		});
		this.initFile(data);	
	},
	initFile:function(o){
		this.files.removeAll(true);
		var conn = new Ext.data.Connection({
			url:'../superviseIssue/searchUpLoadFiles.form?timesnap=' + Date.parse(new Date()),
			method:'post'
		})
		Utils.request(conn,{
			params:{superviseId:o.superviseId},
			scope:this,
			success:function(data){
				var files=data.result;
				for(var i=0;i<files.length;i++){
					this.scope.addFile(files[i]);
				}
				this.scope.files.doLayout();
			}
		});
	},
	addFile:function(o){
		var href='../superviseIssue/downloadFile.form?fileId='+o.ACCESSORY_ID+'&timesnap=' + Date.parse(new Date());
		var lbLink=new Ext.form.Label({
			html:'<a href="'+href+'">'+o.ACCESSORY_NAME+'</>',
			width:320
		});	    	
		this.files.add(lbLink);	    
	}	
});

